package events

import "time"

// DomainEvent 领域事件接口
type DomainEvent interface {
	EventID() string       // 事件ID
	OccurredOn() time.Time // 事件发生时间
	EventName() string     // 事件名称
}

// BaseEvent 事件基类
type BaseEvent struct {
	eventID    string
	occurredOn time.Time
}

func NewBaseEvent() BaseEvent {
	return BaseEvent{
		eventID:    generateEventID(),
		occurredOn: time.Now(),
	}
}

func (e BaseEvent) EventID() string {
	return e.eventID
}

func (e BaseEvent) OccurredOn() time.Time {
	return e.occurredOn
}

func generateEventID() string {
	return "event_" + time.Now().Format("20060102150405.000000")
}
